package com.masterclient.app.modules.shop.adapter;

import android.content.Context;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.eoner.baselibrary.utils.ScreenUtils;
import com.eoner.baselibrary.utils.ViewTransformUtil;
import com.masterclient.app.R;
import com.masterclient.app.modules.shop.beans.DealerItemBean;
import com.masterclient.app.utils.CommonUtil;

import java.util.HashMap;
import java.util.Map;

import jp.wasabeef.glide.transformations.RoundedCornersTransformation;

public class DealerItemAdapter extends BaseQuickAdapter<DealerItemBean, BaseViewHolder> {

    private Context mContext;

    public DealerItemAdapter(Context mContext) {
        super(R.layout.item_dealer);
        this.mContext = mContext;
    }

    @Override
    protected void convert(BaseViewHolder helper, DealerItemBean item) {
        helper.setText(R.id.tv_title, item.title);
        ViewTransformUtil.glideImageView(mContext, item.imgUrl, helper.getView(R.id.image),
                new RoundedCornersTransformation(ScreenUtils.dp2px(7), 0),
                R.mipmap.defaults, ScreenUtils.dp2px(60), ScreenUtils.dp2px(60));
        helper.getView(R.id.view_item).setOnClickListener(v -> {
            Map<String, String> map= new HashMap<>();
            map.put("target",item.redirectUrl);
            map.put("target_id",item.redirectId);
            CommonUtil.goAnyWhereBundle(mContext,map);
        });
    }
}
